const baseApi1 = 'http://192.168.1.166:8888/report-server/'
const baseApi2 = 'http://192.168.2.53:8888/report-server/'

//所有筛选下拉框数据接口
export function getSearchItems (url) {
  let Url = baseApi1 + url;
  return window.axios.get(Url)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 定点医院医疗费用控制监测分析
export function getChartItem1 (url, areaCode,  costType,  medicalCategory) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 2013年-2018年患者次/人均费用增长趋势分析
export function getChartItem2 (url, areaCode, queryYear, hospLevel ) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 2013年-2018年患者次/人均费用增长趋势分析
export function getChartItem3 (url, areaCode,  medicalCategory, countAvgFlag) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    countAvgFlag,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 患者人均/次均医药费用增长比较分析TOP6
export function getChartItem4 (url, areaCode, countAvgFlag, medicalCategory, queryYear) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    countAvgFlag,
    medicalCategory,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 2013年-2018年参保患者个人支出比例增长趋势分析
export function getChartItem5 (url, areaCode, medicalCategory, hospLevel) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 参保患者个人支出比例分解分析
export function getChartItem6 (url, year, planAreaId, hospitalId, insuredTypeId) {
  let Url = baseApi1 + url;
  const data = Object.assign({}, {
    year,
    planAreaId,
    hospitalId,
    insuredTypeId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 2013年-2018年医保目录外费用比例增长趋势分析
export function getChartItem7 (url, areaCode, medicalCategory, hospLevel) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    medicalCategory,
    hospLevel
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 医保目录外费用比例比较分析TOP6
export function getChartItem8(url, areaCode, hospLevel, medicalCategory, queryYear) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    medicalCategory,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 定点医院医疗费用控制监测分析详情
export function getChartItemDetail1 (url, queryYear, areaCode, costType, medicalCategory) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    queryYear,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//
export function getChartItemDetail2 (url, areaCode, queryYear, costType , medicalCategory) {
  let Url = baseApi2 + url;
  const data = Object.assign({}, {
    areaCode,
    queryYear,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      console.log(res.data)
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
